package com.wenbai.servicelightluxurystickers.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Response<T> {
    private int code;
    private String msg;
    private T data;

    // 静态方法用于快速构建成功的响应
    public static <T> Response<T> success(T data) {
        return new Response<>(200, "操作成功", data);
    }

    public static <T> Response<T> success(String msg) {
        return new Response<>(200, msg, null);
    }

    public static <T> Response<T> success(T data, String msg) {
        return new Response<>(200, msg, data);
    }

    // 静态方法用于快速构建失败的响应
    public static <T> Response<T> error() {
        return new Response<>(500, "系统错误", null);
    }

    public static <T> Response<T> error(String msg) {
        return new Response<>(500, msg, null);
    }
}